package com.liuwei.assemble.vo;

import com.baomidou.mybatisplus.annotation.DbType;
import com.liuwei.assemble.constants.DBDriverEnum;


public class GeneratorReqVO {
    private String type;
	private String driverName;
	private String username;
	private String password;
	private String connection;
	private int port;
	private String databaseName;
	private String author;
	private String[] tableNames;
	//项目类型，，目前只支持springboot
	private String projectType;
	//前端框架类型
	private String webType;
	private String projectName;

	private DbType dbType;
	private String connectionUrl;

	//对应的包名
	private String parent;
	private String entity;
	private String mapper;
	private String xml;
	private String service;
	private String serviceImpl;
	private String controller;
	private String idGenerator;
	//添加tgop日志--elk
	private String logtype = "logback";
	//是否启用redisCache缓存
	private boolean enableRedisCache;
	private String redisHost;
	private String redisPassword;
	private int redisPort;

	private boolean enableMicroService;

	private String specifiedTable;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getConnection() {
        return connection;
    }

    public void setConnection(String connection) {
        this.connection = connection;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getParent() {
        return parent;
    }

    public void setParent(String parent) {
        this.parent = parent;
    }

    public String getEntity() {
        return entity;
    }

    public void setEntity(String entity) {
        this.entity = entity;
    }

    public String getMapper() {
        return mapper;
    }

    public void setMapper(String mapper) {
        this.mapper = mapper;
    }

    public String getXml() {
        return xml;
    }

    public void setXml(String xml) {
        this.xml = xml;
    }

    public String getService() {
        return service;
    }

    public void setService(String service) {
        this.service = service;
    }

    public String getServiceImpl() {
        return serviceImpl;
    }

    public void setServiceImpl(String serviceImpl) {
        this.serviceImpl = serviceImpl;
    }

    public String getController() {
        return controller;
    }

    public void setController(String controller) {
        this.controller = controller;
    }

    public String getDriverName() {
    	return this.driverName;
    }
    
    public DbType getDbType(){
        if(this.dbType==null){
            if(DbType.MYSQL.getDb().equals(this.type)){
                this.dbType = DbType.MYSQL;
            }else if(DbType.SQL_SERVER.getDb().equals(this.type)){
                this.dbType = DbType.SQL_SERVER;
            }
        }
        return this.dbType;
    }
    
    public String getDriverNameFromType() {
    	return DBDriverEnum.getDriverName(this.dbType.getDb());
    }

    public String getConnectionUrl(){
        if(connectionUrl==null){
            switch (getDbType()){
                case MYSQL:connectionUrl = "jdbc:mysql://"+this.connection+":"+this.port+"/"+this.databaseName+"?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true";break;
                case SQL_SERVER:connectionUrl = "jdbc:sqlserver://"+this.connection+":"+this.port+"; DatabaseName="+this.databaseName;break;
            }

        }
        return connectionUrl;
    }

    public String getDatabaseName() {
        return databaseName;
    }

    public void setDatabaseName(String databaseName) {
        this.databaseName = databaseName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String[] getTableNames() {
        return tableNames;
    }

    public void setTableNames(String[] tableNames) {
        this.tableNames = tableNames;
    }

    public String getProjectType() {
        return projectType;
    }

    public void setProjectType(String projectType) {
        this.projectType = projectType;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getWebType() {
        return webType;
    }

    public void setWebType(String webType) {
        this.webType = webType;
    }

    public String getIdGenerator() {
        return idGenerator;
    }

    public void setIdGenerator(String idGenerator) {
        this.idGenerator = idGenerator;
    }

    public String getLogtype() {
        return logtype;
    }

    public void setLogtype(String logtype) {
        this.logtype = logtype;
    }

    public boolean isEnableRedisCache() {
        return enableRedisCache;
    }

    public void setEnableRedisCache(boolean enableRedisCache) {
        this.enableRedisCache = enableRedisCache;
    }

    public void setDbType(DbType dbType) {
        this.dbType = dbType;
    }

    public void setConnectionUrl(String connectionUrl) {
        this.connectionUrl = connectionUrl;
    }

    public String getRedisHost() {
        return redisHost;
    }

    public void setRedisHost(String redisHost) {
        this.redisHost = redisHost;
    }

    public String getRedisPassword() {
        return redisPassword;
    }

    public void setRedisPassword(String redisPassword) {
        this.redisPassword = redisPassword;
    }

    public int getRedisPort() {
        return redisPort;
    }

    public void setRedisPort(int redisPort) {
        this.redisPort = redisPort;
    }

    public boolean isEnableMicroService() {
        return enableMicroService;
    }

    public void setEnableMicroService(boolean enableMicroService) {
        this.enableMicroService = enableMicroService;
    }

    public String getSpecifiedTable() {
        return specifiedTable;
    }

    public void setSpecifiedTable(String specifiedTable) {
        this.specifiedTable = specifiedTable;
    }
}
